<div class="layui-form hisi-search">
    <form action="{:url()}" method="get" id="hisi-table-search">
        <div class="layui-form-item">
            <label class="layui-form-label">标题</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input field-title"  name="title" placeholder="请输入标题">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">作者</label>
            <div class="layui-input-inline">
                <select name="author_id" class="layui-input field-author_id" lay-verify="required" lay-search="">
                  <option value="">直接选择或搜索选择</option>
                  {volist name="authors" id='vo'}
                  <option value="{$vo.id}">{$vo.nickname}</option>
                  {/volist}
                </select>
            </div>
        </div>
 {if Request::action() != 'vote'}
        <div class="layui-form-item">
            <label class="layui-form-label">分类</label>
            <div class="layui-input-inline">
                <select name="cate_id" class="layui-input field-cate_id" lay-verify="required" lay-search="">
                  <option value="">直接选择或搜索选择</option>
                  {volist name="cates" id='vo'}
                  <option value="{$vo.id}">{$vo.name}</option>
                  {/volist}
                </select>
            </div>
        </div>
        {/if}
        <div class="layui-form-item hisi-search-btn">
            <div class="layui-input-inline">
                <button type="submit" class="layui-btn layui-btn-normal layui-icon layui-icon-search">执行</button>
            </div>
        </div>
    </form>
</div>

<table id="dataTable"></table>
<script type="text/html" title="状态模板" id="statusTpl">
    <input type="checkbox" name="status" value="{{ d.status }}" lay-skin="switch" lay-filter="switchStatus" lay-text="显示|隐藏" {{ d.status == 1 ? 'checked' : '' }} {{ d.system == 1 ? 'disabled' : '' }} data-href="{:url('status')}?id={{ d.id }}">
</script>

<script type="text/html" title="排序模板" id="sortTpl">
    <input type="text" class="layui-input hisi-ajax-input input-sort" onkeyup="value=value.replace(/[^\d]/g,'')" value="{{ d.sort }}" data-value="{{ d.id }}" data-href="{:url('sort')}?id={{ d.id }}">
</script>
<script type="text/html" id="toolbar">
    <div class="layui-btn-group fl">
        <a href="{:url('add')}" class="layui-btn layui-btn-primary layui-btn-sm layui-icon layui-icon-add-circle-fine hisi-iframe" hisi-data="{width: '600px', height: '600px'}" title="添加">&nbsp;添加</a>
    </div>
</script>
<script type="text/html" title="操作按钮模板" id="buttonTpl">
    <a href="{:url('edit')}?id={{ d.id }}" class="layui-btn layui-btn-xs layui-btn-normal hisi-iframe" hisi-data="{width: '470px', height: '400px'}" title="修改">修改</a>
    <a href="{:url('del')}?id={{ d.id }}" class="layui-btn layui-btn-xs layui-btn-danger j-tr-del  confirm">删除</a>
</script>
<script type="text/html" id="imgTpl">
    <img src="{{ d.img }}" alt="" class="img">
</script>

{include file="system@block/layui" /}
<script type="text/javascript">

    layui.use(['table','jquery'], function() {
        var table = layui.table;
        var $ = layui.jquery;
        table.render({
            elem: '#dataTable'
            ,url: '{:url()}' //数据接口
            ,page: true //开启分页
            ,limit: 20
            ,skin: 'row'
            ,even: true
            ,text: {
                none : '暂无相关数据'
            }
            ,toolbar: '#toolbar'
            ,defaultToolbar: ['filter']
            ,cols: [[ //表头
                {type:'checkbox'}
                ,{field: 'id', title: 'ID',width:50}
                 {if Request::action() == 'vote'}
                ,{field: 'vote', title: '票数'}
                {/if}
                ,{field: 'title', title: '图片标题'}
                ,{field: 'nickname', title: '作者'}
                ,{field: 'cate_name', title: '图片分类'}
                ,{field: 'img', title: '图片',templet:function(d){
                    return '<div onclick="show_img(this)" ><img src="'+d.img+'" alt="" width="50px" height="50px"></a></div>';
                }}
               
                {if Request::action() != 'vote'}
                ,{field: 'sort', title: '排序',templet:'#sortTpl'}
                ,{field: 'status', title: '状态', templet:'#statusTpl'}
                ,{title: '操作', templet: '#buttonTpl', width:150}
                 {/if}
            ]]
        });

    });
            //显示大图片
        function show_img(t) {
            var t = $(t).find("img");
            //页面层
            layer.open({
                type: 1,
                skin: 'layui-layer-rim', //加上边框
                 area: ['80%', '80%'], //宽高
                shadeClose: true, //开启遮罩关闭
                end: function (index, layero) {
                    return false;
                },
                content: '<div style="text-align:center"><img src="' + $(t).attr('src') + '" /></div>'
            });
        }
</script>